package de.baumann.browser.utils.web3j

import android.os.AsyncTask
import android.util.Log
import android.widget.TextView
import java.math.BigDecimal

class MyPowerTask(var textView: TextView, var url: String, var a: String, var ca: String) : AsyncTask<String, Int, BigDecimal>() {
    override fun doInBackground(vararg p0: String?): BigDecimal {
        val balance = TokenUtil.getPower(url, a, ca)
                ?: return BigDecimal(0.0000).setScale(4, BigDecimal.ROUND_DOWN)
        return balance.setScale(4, BigDecimal.ROUND_DOWN)
    }

    override fun onPostExecute(result: BigDecimal?) {
        super.onPostExecute(result)
        textView.text = "算力值：${result.toString()}"
    }
}